// 에러메시지 출력
//window.onerror = ErrorSetting
function ErrorSetting(msg, fileLoc, lineNo)
{
	msgStr = "에러 출력용으로 파일 위치와 라인이 상이할 수 있습니다. <br>Robiie 에게 해당 에러를 알려주시기 바랍니다.";
	alert("Error Message : " + msg + "\nFile Location : " + fileLoc + "\nLine Number : " + lineNo + "\n\n" + msgStr);
	return ture;
}

//## 공통 초기 호출 함수
function fnCommonInit()
{
	fnGetMemos();
}

//## 시스템 메모 호출
function fnGetMemos()
{
	var valUrl = "/action/common/listMemo.asp";
	var param = "";

	if (xMode=="Debug") window.open(valUrl+'?xMode=debug&'+param);

	$.ajax({
		url: valUrl,
		type: 'POST',
		dataType: 'xml',
		data: param,
		success: function(xml){
			
			//## 로그인 체크
			fnSessionCheck($(xml).find("MSG").text());
			fnMemoReset();
			$("#memoSeqs").val($(xml).find("memoSeqs").text());
			$("#memoTitle").html($(xml).find("userNm").text()+" 님의 메모");
			$("#memoContents").html($(xml).find("memos").text());
			if ($(xml).find("userNm").text()) $("#systemMemo").css("display",""); 
			
			setTimeout("fnGetMemos()",300000);
			
		},
		error: function(xml){
			alert('Error!!');
			alert(xml.responseText);
		}
	});
}

//## 시스템 메모 확인
function fnMemoConfirm()
{
	var valUrl = '/action/common/saveMemo.asp';
	var param  = "memoSeqs="+$("#memoSeqs").val();
	
	if (xMode=="Debug") window.open(valUrl+'?xMode=debug&'+param);

	$.ajax({
		url: valUrl,
		type: 'POST',
		dataType: 'xml',
		data: param,
		success: function(xml){
			fnSessionCheck($(xml).find("MSG").text());
			if ($(xml).find("MSG").text() == "Save OK!")
			{
				alert("Save OK!");
				fnLayerClose('systemMemo');
			}
			else alert($(xml).find("MSG").text());
		},
		error: function(xml){
			alert('Error!!');
			alert(xml.responseText);
		}
	});
}

//## 메모 정보 초기화
function fnMemoReset()
{
	$("#memoSeqs").val("");
	$("#memoTitle").html("");
	$("#memoContents").html("");
}


// 오늘 날짜 구하기
function fnGetToday()
{
		var newDate = new Date();
		var yy = newDate.getFullYear();
		var mm = newDate.getMonth()+1;
		var dd = newDate.getDate();
		if (mm < 10) mm ="0"+mm;
		if (dd < 10) dd ="0"+dd;
		var toDay = yy + "-" + mm + "-" + dd;
		return toDay;
}

// 화면에 접속시 상단의 메인 메뉴 세팅하는 함수
function setMainMenu()
{
	var tabLength = $("#MenuTab").find("tr").find("td").length;
	var curUrl = window.location + " ";
	
	if (G_destFolder == "/chrome/")
	{
		if (curUrl.indexOf("jobOrder") != -1) var posit = "1";
		if (curUrl.indexOf("equipBreak") != -1) var posit = "2";
		if (curUrl.indexOf("product") != -1) var posit = "3";
		if (curUrl.indexOf("srcStore") != -1) var posit = "4";
		if (curUrl.indexOf("comCode") != -1) var posit = "5";
	}
	else
	{
	if (curUrl.indexOf("dashBoard") != -1) var posit = "1";
	if (curUrl.indexOf("board") != -1) var posit = "1";
	if (curUrl.indexOf("statistics") != -1) var posit = "1";
	if (curUrl.indexOf("graph") != -1) var posit = "1";
	if (curUrl.indexOf("jobOrder") != -1) var posit = "2";
	if (curUrl.indexOf("extraOrder") != -1) var posit = "2";
	if (curUrl.indexOf("unitProcess") != -1) var posit = "3";
	if (curUrl.indexOf("product") != -1) var posit = "4";
	if (curUrl.indexOf("src") != -1) var posit = "5";
	if (curUrl.indexOf("srcStore") != -1) var posit = "5";
	if (curUrl.indexOf("equipBreak") != -1) var posit = "5";
	if (curUrl.indexOf("bizBill") != -1) var posit = "5";
	if (curUrl.indexOf("order") != -1) var posit = "6";
	if (curUrl.indexOf("company") != -1) var posit = "6";
	if (curUrl.indexOf("estimate") != -1) var posit = "6";
	if (curUrl.indexOf("comCode") != -1) var posit = "7";
	if (curUrl.indexOf("member") != -1) var posit = "7";
	if (curUrl.indexOf("offDayWork") != -1) var posit = "7";
	if (curUrl.indexOf("accountIn") != -1) var posit = "8";
	if (curUrl.indexOf("accountOut") != -1) var posit = "8";
	if (curUrl.indexOf("article") != -1) var posit = "8";
	if (curUrl.indexOf("accountStat") != -1) var posit = "8";
	if (curUrl.indexOf("groupWork") != -1) var posit = "9";
	if (curUrl.indexOf("groupWorkAppr") != -1) var posit = "9";
	if (curUrl.indexOf("groupBbs") != -1) var posit = "9";
	}

	for (k=1; k<tabLength; k++)
	{
		if (k != posit) var css = "tTD_t0bl";
		else var css = "lTD_t00l";
		$("#MenuTab").find("tr").find("td").eq(k).addClass(css);		
	}
}

// 페이지 이동 함수
function mvPage(dest)
{	
	if (dest.indexOf("dashBoard") != -1) var posit = "10";
	if (dest.indexOf("board") != -1) var posit = "11";
	if (dest.indexOf("graph") != -1) var posit = "12";
	if (dest.indexOf("jobOrder") != -1) var posit = "20";
	if (dest.indexOf("extraOrder") != -1) var posit = "21";
	if (dest.indexOf("unitProcess") != -1) var posit = "30";
	if (dest.indexOf("product") != -1) var posit = "40";
	if (dest.indexOf("src") != -1) var posit = "50";
	if (dest.indexOf("srcStore") != -1) var posit = "51";
	if (dest.indexOf("equipBreak") != -1) var posit = "52";
	if (dest.indexOf("bizBill") != -1) var posit = "53";
	if (dest.indexOf("order") != -1) var posit = "60";
	if (dest.indexOf("company") != -1) var posit = "61";
	if (dest.indexOf("estimate") != -1) var posit = "62";
	if (dest.indexOf("comCode") != -1) var posit = "70";
	if (dest.indexOf("member") != -1) var posit = "71";	
	if (dest.indexOf("offDayWork") != -1) var posit = "72";	
	if (dest.indexOf("accountIn") != -1) var posit = "80";
	if (dest.indexOf("accountOut") != -1) var posit = "81";
	if (dest.indexOf("article") != -1) var posit = "82";
	if (dest.indexOf("accountStat") != -1) var posit = "83";
	if (dest.indexOf("groupWork") != -1) var posit = "90";
	if (dest.indexOf("groupAppr") != -1) var posit = "91";
	if (dest.indexOf("groupBbs") != -1) var posit = "92";

	if (G_perm.indexOf("/"+posit+"/") == -1)
	{
		alert("권한이 없습니다!");
		return;
	}
	else 
	{
		//location.href = G_destFolder+dest+".asp";
		if (dest == "dashBoard2" ) location.href = "dashBoard.asp?cp=on";
		else location.href = dest+".asp";
		//if (posit>90) window.open(dest+".asp");
		//else 	location.href = dest+".asp";
	}
}

// 공지사항 가져오기
function fnGetTopNoice(target)
{
	var valUrl = "/action/common/listNotice.asp";
	var param = "";

	if (xMode=="debug") window.open(valUrl+'?xMode=debug&'+param);

	$.ajax({
		url: valUrl,
		type: 'POST',
		dataType: 'xml',
		data: param,
		success: function(xml){
			//## 로그인 체크
			fnSessionCheck($(xml).find("MSG").text());
			var topNotice = "";
			$(xml).find("TopNotice").each(function()
			{
				var seq = $(this).find("seq").text();
				var titles = $(this).find("titles").text();
				var wdate = $(this).find("wdate").text();
				wdate = "("+wdate+")";
				if (topNotice) topNotice += " / ";
				//topNotice += "<a href=\"board.asp?seq="+seq+"\" target=\"_blank\"><b>[공지]</b> "+titles+"</a>";
				topNotice += "<a href=\"javascript:fnShowNotice('"+seq+"')\"><b>[공지]</b> "+titles+wdate+"</a>";

			});
			if (!topNotice) topNotice += "&nbsp;";
			$("#"+target).html(topNotice);

		},
		error: function(xml){
			alert('Error!!');
			alert(xml.responseText);
		}
	});
}

function fnShowNotice(seq)
{
	var valUrl = "/action/board/view.asp";
	var param = "seq="+seq;

	if (xMode=="debug") window.open(valUrl+'?xMode=debug&'+param);

	$.ajax({
		url: valUrl,
		type: 'POST',
		dataType: 'xml',
		data: param,
		success: function(xml){
			
			//## 로그인 체크
			fnSessionCheck($(xml).find("MSG").text());

			$("#vTitles").html($(xml).find("titles").text());
			$("#contents").val($(xml).find("contents").text());

		},
		error: function(xml){
			alert('Error!!');
			alert(xml.responseText);
		}
	});
	$("#noticeContents").css("top",83);
	$("#noticeContents").css("left",220);
	//$("#noticeContents").css("display","");
	$("#noticeContents").show('slow');
}

function fnLayerClose(target)
{
	$("#"+target).css("display","none");
}

function intervalNotice()
{
	fnGetTopNoice("topNotice");
	setTimeout("intervalNotice();",5*60*1000);
}

//날짜 더하기 함수 [예제] 2008-01-01 에 3 일 더하기 ==> addDate("d", 3, "2008-08-01") 
function addDate(pInterval, pAddVal, pYyyymmdd)
{
	var yyyy;
	var mm;
	var dd;
	var cDate;
	var oDate;
	var cYear, cMonth, cDay;

	//if (pDelimiter != "") 
	//{
	//	pYyyymmdd = pYyyymmdd.replace(eval("/\\" + pDelimiter + "/g"), "");
	//}
	pYyyymmdd = pYyyymmdd.split("-").join("");


	yyyy = pYyyymmdd.substr(0, 4);
	mm  = pYyyymmdd.substr(4, 2);
	dd  = pYyyymmdd.substr(6, 2);

	if (pInterval == "yyyy") 
	{
		yyyy = (yyyy * 1) + (pAddVal * 1); 
	} 
	else if (pInterval == "m") 
	{
		mm  = (mm * 1) + (pAddVal * 1);
	} 
	else if (pInterval == "d") 
	{
		dd  = (dd * 1) + (pAddVal * 1);
	}


	cDate = new Date(yyyy, mm - 1, dd) // 12월, 31일을 초과하는 입력값에 대해 자동으로 계산된 날짜가 만들어짐.
	cYear = cDate.getFullYear();
	cMonth = cDate.getMonth() + 1;
	cDay = cDate.getDate();

	cMonth = cMonth < 10 ? "0" + cMonth : cMonth;
	cDay = cDay < 10 ? "0" + cDay : cDay;
/*
	if (pDelimiter != "") {
		return cYear + pDelimiter + cMonth + pDelimiter + cDay;
	} 
	else 
	{
		return cYear + cMonth + cDay;
	}
*/
	return cYear +"-"+ cMonth +"-"+ cDay;
}

// 천단위 코마(,) 찍기
function commify(n,target) 
{
	var reg = /(^[+-]?\d+)(\d{3})/;   // 정규식
	n += '';                          // 숫자를 문자열로 변환

	var num = "";
	for (k=0; k<=n.length; k++)
	{
		if (n.substr(k,1) != "," && n.substr(k,1) != "") num += n.substr(k,1);
	}  

	while (reg.test(num))
	num = num.replace(reg, '$1' + ',' + '$2');

	eval(target).value = num;
}


// 천단위 코마(,) 찍기
function commify2(obj) 
{
	var reg = /(^[+-]?\d+)(\d{3})/;   // 정규식
	n = obj.value;
	n += '';                          // 숫자를 문자열로 변환

	var num = "";
	for (k=0; k<=n.length; k++)
	{
		if (n.substr(k,1) != "," && n.substr(k,1) != "") num += n.substr(k,1);
	}  

	while (reg.test(num))
	num = num.replace(reg, '$1' + ',' + '$2');

	obj.value = num;
}

function getNumWithComma(n)
{
     var reg = /(^[+-]?\d+)(\d{3})/;   // 정규식
     n += '';                          // 숫자를 문자열로 변환

     var num = "";
     for (k=0; k<=n.length; k++)
     {
          if (n.substr(k,1) != "," && n.substr(k,1) != "") num += n.substr(k,1);
     } 

     while (reg.test(num))
     num = num.replace(reg, '$1' + ',' + '$2');

	 return num;
     //eval(target).value = num;
}

function URLencode(temp)
{
   return encodeURIComponent(temp);
}

function fnNumOnly(obj)
{
	var no = obj.value;
	var target = obj.id;
	var onlyNo = no.split("-").join("");
	$("#"+target).val(onlyNo);
}

function fnSetDate(obj)
{
	var no = obj.value;
	var target = obj.id;
	var chDate = no.substr(0,4) + "-" + no.substr(4,2) + "-" + no.substr(6,2)
	$("#"+target).val(chDate);
}

function mouseOnTD(seq, bool)
{

	var oTD = eval("document.all.listID" + seq);
	var len = oTD.length;
	var borderStyle = "1 solid slategray";

	if (bool){
		for(var i =0; i < len ; i++){
			oTD[i].style.borderTop = borderStyle;
			oTD[i].style.borderBottom = borderStyle;
			oTD[i].style.cursor = "default";
		}

	//	oTD[0].style.borderLeft = borderStyle;
		oTD[0].style.backgroundColor = "#F5F9FE";
		oTD[len-1].style.borderRight = borderStyle;

	}else{

		for(var i =0; i < len; i++){
			oTD[i].style.border = "";
		}
		oTD[0].style.backgroundColor = "";
	}

}

function sendFormData(Url,mode,targetNm) 
{ 
	if(mode=='know') window.open('',targetNm);
	else window.open('',targetNm,'width=1024,height=768,top=50,left=50,scrollbars=1,toolbar=yes,menubar=yes,status=yes,location=yes');
	document.goQna.target = targetNm;
	document.goQna.action = Url;
	document.goQna.confirmmode.value = mode;
	document.goQna.submit();
} 

function gogoogle() 
{ 
	window.open('http://www.google.com/calendar/render?hl=ko','win','width=1024,height=768,top=50,left=50,scrollbars=1,toolbar=yes,menubar=yes,status=yes,location=yes') 
} 

function overTr(chTblTr)
{
	chTblTr.style.color = "#FF0066";
	chTblTr.style.background = "#F2F2F2";
}

function outTr(chTblTr)
{
	chTblTr.style.color = "#000000";
	chTblTr.style.background = "#FFFFFF";
}

//Table 생성 함수
// tbId : Form Name
// addValue : Content Array
// bgColor : Tr Background Color
// exAlign : Align (구분자 ,)
// clickFunction : Tr Click Function
function mkTable(tbId, addValue, bgColor, exAlign, clickFunction) // addValue는 배열로 들어와야 한다. / exAlign , 로 구분하여 정렬한다.
{
	var orgTblBd = document.getElementById(tbId).getElementsByTagName("thead")[0];
	var orgTblTr = orgTblBd.children[0];

	var adTblBd = document.getElementById(tbId).getElementsByTagName("tbody")[0];
	var adTblTr = document.createElement("tr");
	if(orgTblTr.getAttributeNode("class").value) 
	{
		var adTrClass = document.createAttribute("class");
		adTrClass.value = orgTblTr.getAttributeNode("class").value;
		adTblTr.setAttributeNode(adTrClass);
	}
	if(orgTblTr.getAttributeNode("align").value) 
	{
		var adTrAlign = document.createAttribute("align");
		adTrAlign.value = orgTblTr.getAttributeNode("align").value;
		adTblTr.setAttributeNode(adTrAlign);
	}
	if(orgTblTr.getAttributeNode("height").value) 
	{
		var adTrHeight = document.createAttribute("height");
		adTrHeight.value = orgTblTr.getAttributeNode("height").value;
		adTblTr.setAttributeNode(adTrHeight);
	}
	if(bgColor)
	{
		var adTrBgcolor = document.createAttribute("bgcolor");
		adTrBgcolor.value = bgColor;
		adTblTr.setAttributeNode(adTrBgcolor);
	}
//	adTblTr.style.fontWeight = "bold";
	
	if(clickFunction) 
	{
		adTblTr.style.cursor = "hand";

		//adTblTr.onclick=function()
		//{
		//	eval(clickFunction);
		//}

		adTblTr.onmouseover=function()
		{
			eval("javascript:overTr(this);");
		}
		adTblTr.onmouseout=function()
		{
			eval("javascript:outTr(this);");
		}
	}

	// 기존 Tr 의 구성 요소를 구해서 추가되는 Tr에 적용.
	var adTblTd = new Array();
	var adTdClass = new Array();
	var adTdAlign = new Array();
	var adTdWidth = new Array();
	var divAlign = new Array();
	if (exAlign) divAlign = exAlign.split(",");	
	for(var rw=0; rw<orgTblTr.children.length; rw++)
	{
		adTblTd[rw] = document.createElement("td");  
		if (rw>0)
		{
			adTblTd[rw].onclick=function()
			{
				eval(clickFunction);
			} 
		}
		if (!exAlign) divAlign[rw] = "";
		
		if(orgTblTr.children[rw].getAttributeNode("class").value) 
		{
			adTdClass[rw] = document.createAttribute("class");
			adTdClass[rw].value = orgTblTr.children[rw].getAttributeNode("class").value;
			adTblTd[rw].setAttributeNode(adTdClass[rw]);
		}
		if(orgTblTr.children[rw].getAttributeNode("width").value) 
		{
			adTdWidth[rw] = document.createAttribute("width");
			adTdWidth[rw].value = orgTblTr.children[rw].getAttributeNode("width").value;
			adTblTd[rw].setAttributeNode(adTdWidth[rw]);
		}
		if (divAlign[rw])
		{
			adTblTd[rw].style.textAlign = divAlign[rw]; 
		}
		else if (orgTblTr.children[rw].getAttributeNode("align").value)
		{
			adTblTd[rw].style.textAlign = orgTblTr.children[rw].getAttributeNode("align").value; 
		}
        adTblTd[rw].innerHTML = addValue[rw];
		adTblTr.appendChild(adTblTd[rw]);
	}	

    adTblBd.appendChild(adTblTr); 
}

function mkTable2(tbId, addValue, bgColor, exAlign, clickFunction, boldLine) // addValue는 배열로 들어와야 한다. / exAlign , 로 구분하여 정렬한다.
{
	var orgTblBd = document.getElementById(tbId).getElementsByTagName("thead")[0];
	var orgTblTr = orgTblBd.children[0];

	var adTblBd = document.getElementById(tbId).getElementsByTagName("tbody")[0];
	var adTblTr = document.createElement("tr");
	if(orgTblTr.getAttributeNode("class").value) 
	{
		var adTrClass = document.createAttribute("class");
		adTrClass.value = orgTblTr.getAttributeNode("class").value;
		adTblTr.setAttributeNode(adTrClass);
	}
	if(orgTblTr.getAttributeNode("align").value) 
	{
		var adTrAlign = document.createAttribute("align");
		adTrAlign.value = orgTblTr.getAttributeNode("align").value;
		adTblTr.setAttributeNode(adTrAlign);
	}
	if(orgTblTr.getAttributeNode("height").value) 
	{
		var adTrHeight = document.createAttribute("height");
		adTrHeight.value = orgTblTr.getAttributeNode("height").value;
		adTblTr.setAttributeNode(adTrHeight);
	}
	if(bgColor)
	{
		var adTrBgcolor = document.createAttribute("bgcolor");
		adTrBgcolor.value = bgColor;
		adTblTr.setAttributeNode(adTrBgcolor);
	}
//	adTblTr.style.fontWeight = "bold";
	
	if(clickFunction) 
	{
		adTblTr.style.cursor = "hand";
	}

	// 기존 Tr 의 구성 요소를 구해서 추가되는 Tr에 적용.
	var adTblTd = new Array();
	var adTdClass = new Array();
	var adTdAlign = new Array();
	var adTdWidth = new Array();
	var divAlign = new Array();
	if (exAlign) divAlign = exAlign.split(",");	
	for(var rw=0; rw<orgTblTr.children.length; rw++)
	{
		adTblTd[rw] = document.createElement("td");  
		if (rw>0 && rw<orgTblTr.children.length-2)
		{
			adTblTd[rw].onclick=function()
			{
				eval(clickFunction);
			} 
		}
		if (!exAlign) divAlign[rw] = "";
		
		if(orgTblTr.children[rw].getAttributeNode("class").value) 
		{
			adTdClass[rw] = document.createAttribute("class");
			//adTdClass[rw].value = orgTblTr.children[rw].getAttributeNode("class").value;
			var divTdClass = orgTblTr.children[rw].getAttributeNode("class").value.split(" ");
			var tdClass = divTdClass[0];
			tdClass = tdClass.replace("tTD_","lTD_");

			if (boldLine == "Y")
			{
				if (rw == 0) tdClass = "TD_0rbl2"; 
				else tdClass = "TD_0rb02"; 
			}
			adTdClass[rw].value = tdClass;
			adTblTd[rw].setAttributeNode(adTdClass[rw]);
		}
		if(orgTblTr.children[rw].getAttributeNode("width").value) 
		{
			adTdWidth[rw] = document.createAttribute("width");
			adTdWidth[rw].value = orgTblTr.children[rw].getAttributeNode("width").value;
			adTblTd[rw].setAttributeNode(adTdWidth[rw]);
		}
		if (divAlign[rw])
		{
			adTblTd[rw].style.textAlign = divAlign[rw]; 
		}
		else if (orgTblTr.children[rw].getAttributeNode("align").value)
		{
			adTblTd[rw].style.textAlign = orgTblTr.children[rw].getAttributeNode("align").value; 
		}
        adTblTd[rw].innerHTML = addValue[rw];
		adTblTr.appendChild(adTblTd[rw]);
	}	

    adTblBd.appendChild(adTblTr); 
}

function clstTable(tbId)
{
	var rmTblBd = document.getElementById(tbId).getElementsByTagName("tbody")[0];
	while (rmTblBd.hasChildNodes())
	{
		var childNod = rmTblBd.children(0);
		rmTblBd.removeChild(childNod);
	}			
}

//## 페이지 이동
function goPage(tbId,page)
{
	if (G_destFolder == "") 
	{
		clstTable(tbId); // 크롬 브라우져가 아닐때만 실행....
		//alert(tbId.substr(tbId.length-1,1));
		var posit = tbId.substr(tbId.length-1,1);
		$("#tr0"+posit+"Result").show();
		setNullRow("loadSpan",posit);
	}
	setTimeout("set"+tbId+"("+page+")",100); 
}

//## 페이징 처리 함수
function fnPaging(gridNm, curPage, totalPage)
{
	var pages = "";
	
	var pageCount=10;
	var	x = 1 + parseInt((curPage-1)/10)*10;
	var y = 0;
	var startPage = x;
	if (totalPage > 0)
	{
		for(var x=startPage; x<=totalPage; x++)
		{
			var nextPage=x+1;   //다음페이지
			var prePage=x-1;    //전페이지
			var z = x % 10;
			var a = x % pageCount;
			if (startPage > 1 && y==0) 
			{
				pages += "<a href=\"javas"+"cript:goPage('"+gridNm+"',"+prePage+")\"><font class=\"normal\">&nbsp;<<&nbsp;</font></a>";
				y = 1;
			}
			if (x==parseInt(curPage,10))
			{
				pages += " <font class=\"accent\">&nbsp;" + x + "&nbsp;</font>";
			}else if(k = 0 || x == totalPage)
			{
				pages += "<a href=\"javas"+"cript:goPage('"+gridNm+"',"+x+")\"><font class=\"normal\">&nbsp;" + x + "&nbsp;</font></a>";
			}else{
				pages += "<a href=\"javas"+"cript:goPage('"+gridNm+"',"+x+")\"><font class=\"normal\">&nbsp;" + x + "&nbsp;</font></a>";
			}
			if (a == 0 && nextPage <= totalPage)
			{
				pages += "<a href=\"javas"+"cript:goPage('"+gridNm+"',"+nextPage+")\"><font class=\"normal\">&nbsp;>>&nbsp;</font></a>";
				x = totalPage;
			}
		}
	}
	return pages;
}

//## 그리드 초기화에서 사용하는 함수
function setNullRow(span, No)
{
	var loadSpan = span + No;
	$("#"+loadSpan).text("Loading");
	drawLoad(No);
}

function drawLoad(No)
{
	var loadSpan = $("#loadSpan"+No).text();
	if(loadSpan.indexOf("Loading") > -1){
	  $("#loadSpan"+No).append(".");
	  if($("#loadSpan"+No).text() =="Loading..........")
	  {
		 $("#"+loadSpan).text("Loading");
	  }
			
	   setTimeout("drawLoad('"+No+"')",500);
	}
}

function fnEnter(frm)
{
	if(event.keyCode == "13")
	{
		setTimeout(frm+"();",500);
		return;
	}
}

function msgSize(value)  // SMS 문자 사이즈 구하기
{
	var tmpStr;
	var temp = 0;
	var oneChar;
	var tCount;
	tCount = 0;
	tmpStr = new String(value);
	temp = tmpStr.length;
	for (k=0; k<temp; k++)
	{
		oneChar = tmpStr.charAt(k);
		if(escape(oneChar).length > 4) { tCount += 2; }
		else if (oneChar != "\r") { tCount++; }
	}
	return tCount;
}

function textCounter(field, cntField, maxLimit) // // SMS 문자 용량 초과 체크
{
	var trueLength = msgSize(field.value);
	if (trueLength > maxLimit)
	{
		alert("80Byte 초과!!");
		var str = field.value.substring(0, maxLimit);
		field.value = str;
	}
	else cntField.value = trueLength;
}

//## 노아텍 전용 ######################################################################

//## 회사 정보 가져오기
function fnFindCompany(compNm, compCd, target)
{
	var valUrl = "/action/common/listCompany.asp";
	var param  = "findCompany="+encodeURIComponent(compNm);
		param  += "&compCd="+compCd;
	if (xMode=="debug") window.open(valUrl+'?xMode=debug&'+param);

	$("#"+target).html("<option value=\"\">-거래처-</option>");
	$.ajax({
		url: valUrl,
		type: 'POST',
		dataType: 'xml',
		data: param,
		success: function(xml){

			$(xml).find("CompList").each(function(idx){
				if (compCd == $(this).find("compCd").text()) var chk = " selected";
				else var chk = "";
				$("#"+target).append("<option value=\""+$(this).find("compCd").text()+"\""+chk+">"+$(this).find("company").text()+"</option>");
			});
		},
		error: function(xml){
			alert('Error!!');
			alert(xml.responseText);
		}
	});
}

//## 제품명 정보 자겨 오기 fnFindProduct
function fnFindProduct(prdNm, prdCd, target)
{
	var valUrl = "/action/common/listProduct.asp";
	var param  = "prdNm="+encodeURIComponent(prdNm);
	if (xMode=="debug") window.open(valUrl+'?xMode=debug&'+param);

	$("#"+target).html("<option value=\"\">-제품명-</option>");
	$.ajax({
		url: valUrl,
		type: 'POST',
		dataType: 'xml',
		data: param,
		success: function(xml){

			$(xml).find("PrdList").each(function(idx){
				if (prdCd == $(this).find("prdCd").text()) var chk = " selected";
				else var chk = "";
				$("#"+target).append("<option value=\""+$(this).find("prdCd").text()+"\""+chk+">"+$(this).find("prdNm").text()+"</option>");
			});
		},
		error: function(xml){
			alert('Error!!');
			alert(xml.responseText);
		}
	});
}

function fnSessionCheck(session)
{
	if (session == "Session Off")
	{
		alert("세션이 종료되었습니다.");
		location.href="/index.asp";
	}
}

function fnLogOut()
{
	location.href="/login.post.asp";
}